﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Teein.Proxy.Bot.Model;
using MongoDB.Driver;

namespace Teein.Proxy.Bot.DAL
{
    public class SiteDAL:IDAL<SiteInfo>
    {

        public bool Insert(SiteInfo model)
        {
            return SQLHelper.Insert<SiteInfo>(model);
        }

        public bool Update(SiteInfo model)
        {
            UpdateDocument ud = new UpdateDocument();
            ud.Add("Name", model.Name);
            ud.Add("Url", model.Url);
            return SQLHelper.Update<SiteInfo>(new QueryDocument("_id", model.PID), ud);
        }

        public bool Delete(SiteInfo model)
        {
            return SQLHelper.Delete<SiteInfo>(new QueryDocument("_id", model.PID));
        }

        public bool Delete(MongoDB.Driver.IMongoQuery mq)
        {
            return SQLHelper.Delete<SiteInfo>(mq);
        }

        public SiteInfo FindOne(MongoDB.Driver.IMongoQuery mq)
        {
            return SQLHelper.FindOne<SiteInfo>(mq);
        }

        public IList<SiteInfo> Find(MongoDB.Driver.IMongoQuery mq)
        {
            return SQLHelper.Find<SiteInfo>(mq);
        }
    }
}
